﻿using System;
using System.Collections.Generic;
using System.Management.Automation;
using T4Scaffolding.Cmdlets;

namespace Caramel.Entities.Scaffolding.Cmdlets
{
	[Cmdlet("Get", "CatalogMetadata")]
	public class GetCatalogMetadataCmdlet : ScaffoldingBaseCmdlet
	{
		public GetCatalogMetadataCmdlet()
			: base()
		{
			this.DataSource = ".";
			this.IncludedSchemas = new List<string>(new[] { "dbo" });
		}

		[Parameter()]
		public string DataSource { get; set; }

		[Parameter(Mandatory = true)]
		public string InitialCatalog { get; set; }

		[Parameter()]
		public IList<string> IncludedSchemas { get; set; }

		[Parameter()]
		public IList<string> IncluuedTables { get; set; }

		protected override void ProcessRecordCore()
		{
			// TEMP!!!
			var provider =
				new Caramel.Entities.Scaffolding.Metadata.SqlServer.SqlServerCatalogMetadataProvider()
				{
					DataSource = this.DataSource,
					InitialCatalog = this.InitialCatalog,
					IncludedSchemas = this.IncludedSchemas,
					IncludedTables = this.IncluuedTables
				};
			
			base.WriteObject(provider.GetCatalogMetadata());
		}
	}
}
